package com.heqiang.config;

import com.heqiang.interceptor.AdminInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


//拦截器的配置类
@Configuration
public class InterceptConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        String[] addInterceptorPaths = {
            "/**"
        };//要拦截的路径
        String[] exceptInterceptorPaths = {
            "/bootstrap/**",
            "/test/**",
            "/images/**",
            "/admin/go/login",
            "/admin/login",
            "/admin/go/error",
        };//不拦截的路径
        registry.addInterceptor(new AdminInterceptor()).addPathPatterns(addInterceptorPaths).excludePathPatterns(exceptInterceptorPaths);
    }
}
